package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.qc.CommonDefect;
import com.qidianit.mes.pro.service.CommonDefectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.security.PublicKey;

/**
 * @Description:
 * @Author: wang fei long
 * @Date: 2025/9/22 0022 - 14:56
 */
@RestController
@RequestMapping("/commonDefect")
public class CommonDefectController {

    @Autowired
    private CommonDefectService commonDefectService;

    @GetMapping("/page")
    public Result<PageInfo<CommonDefect>> selectList(
            CommonDefect commonDefect,
            @RequestParam(defaultValue = "1") int pageNum,
            @RequestParam(defaultValue = "10") int pageSize) {
        return commonDefectService.selectList(commonDefect, pageNum, pageSize);
    }


    @GetMapping("/get/{id}")
    public Result get(@PathVariable("id") Long id){
        return commonDefectService.selectById(id);
    }

    @PostMapping("/add")
    public Result save(@RequestBody CommonDefect commonDefect) {
        return commonDefectService.save(commonDefect);
    }




    @PutMapping("/update")
    public Result updateById(@RequestBody CommonDefect commonDefect) {
        return commonDefectService.updateById(commonDefect);
    }


    @DeleteMapping("/delete/{id}")
    public Result deleteById(@PathVariable Long id) {
        return commonDefectService.deleteById(id);
    }


    @DeleteMapping("/batchDelete")
    public Result batchDelete(@RequestParam Long[] id) {
        return commonDefectService.batchDelete(id);
    }

}

